<!DOCTYPE html>
<html class="x-admin-sm">

{include file="common/static" /}
{include file="common/resources" /}
    <body>

        <div class="layui-fluid">

            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">

                        <div class="layui-card-body ">

                                <div class="layui-form-item">
                                    <label class="layui-form-label">类型</label>
                                    <div class="layui-input-block">
                                        <select name="city" lay-verify="required" id="service">
                                            {volist name="service" id="vo"}
                                                <option value="{$vo.id}">{$vo.service_name}</option>
                                            {/volist}
                                        </select>
                                    </div>
                                </div>

                                <div class="layui-form-item">
                                    <label class="layui-form-label">房间</label>
                                    <div class="layui-input-block">
                                        <select name="city" lay-verify="required" id="room">
                                            {volist name="room" id="v"}
                                            <option value="{$v.id}">{$v.room_num}</option>
                                            {/volist}
                                        </select>
                                    </div>
                                </div>

                                <div class="layui-form-item">
                                    <label class="layui-form-label">负责人</label>
                                    <div class="layui-input-block">
                                        <select name="city" lay-verify="required" id="admin">
                                            {volist name="admin" id="v1"}
                                            <option value="{$v1.id}">{$v1.name}</option>
                                            {/volist}
                                        </select>
                                    </div>
                                </div>

                                <div class="layui-form-item layui-form-text">
                                    <label class="layui-form-label">备注</label>
                                    <div class="layui-input-block">
                                        <textarea name="desc" placeholder="请输入备注" class="layui-textarea"></textarea>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-input-block">
                                        <button class="layui-btn" lay-submit lay-filter="formDemo" onclick="adds()">立即派发</button>
                                    </div>
                                </div>

                        </div>

                    </div>
                </div>
            </div>

        </div>
    </body>

<script>


layui.use('form', function(){
    var form = layui.form;
});

function adds(){
    $.ajax({
        type:"post",
        url: "{:url('home/roomservice/add_publish')}",
        data: {
            service:$('#service').val(),
            room:$('#room').val(),
            admin:$('#admin').val(),
        },
        success: function(data){
            console.log(data);
            toastr.error(data.msg);
            if(data.code == 100){
                setTimeout(function () {
                    layer.closeAll();
                    parent.location.reload();
                },1500);
            }
        }});
}

    /*班次-删除*/
    function member_del(obj, id) {
        layer.confirm('确认要删除吗？',
        function(index) {
            $.ajax({
                type:"post",
                url: "{:url('index/classe/deletes')}",
                data: {
                    id:id
                },
                success: function(data){
                    console.log(data);
                    toastr.error(data.msg);
                    if(data.code == 100){

                        layer.closeAll();
                        $(obj).parents("tr").remove();
                        setTimeout(function () {
                            location.reload();
                        },1000);
                    }
                }});
        });
    }

</script>


</html>